package com.andreiamariei.tema6.services;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.andreiamariei.tema6.entities.Movie;

@SuppressWarnings("unchecked")
@Stateless
public class MovieService {

	@PersistenceContext
	private EntityManager em;
	
	public List<Movie> findAll() {
		List<Movie> entities = em.createQuery(
				"select movie from Movie as movie").getResultList();

		return entities;
	}

	public void create(Movie movie) {
		
		em.persist(movie);
	}
	
	public void remove(Movie movie) {

		em.remove(movie);
	}
}
